package com.qtu.product_service.controller;

import com.qtu.product_service.entity.ReCaregory;
import com.qtu.product_service.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("api/category")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;


    /**
     * 查询一级菜单
     * @return
     */
    @RequestMapping("selectMenus")
    @ResponseBody
    public List selectMenus(String token){
        List<ReCaregory> list = categoryService.selectMenus();
        return list;
    }
    /**
     * 按条件查询商品
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping("selectAll")
    public Map selectAll(String token,ReCaregory reCaregory){
        Map<String,Object>map=new HashMap<>();
        try {
             map = categoryService.selectAll(reCaregory);

            return map;
        } catch (Exception e) {
            e.printStackTrace();
        }
        map.put("all","网络错误请求失败");
        return map;
    }
}
